# test.py

#-------------------- USER START ------------------------
window = (230, 230)
#--------------------  USER END  ------------------------

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.set_windowing(window)
sensor.skip_frames(time = 2000)

template = image.Image("template.pgm")

while(True):
    img = sensor.snapshot()
    roi = img.find_template(template, 0.7)
    img.draw_cross(int(window[0] / 2), int(window[1] / 2), color = (0), size = 8)
    if(roi != None):
        img.draw_rectangle(roi[0], roi[1], roi[2], roi[3], color = (0))
        img.draw_cross(int(roi[0] + roi[2] / 2), int(roi[1] + roi[3] / 2), color = (0))
